package th.go.drr.gps.web.action.usr;

import java.io.File;

import org.apache.log4j.Logger;

import th.go.drr.gps.common.APPCONF;
import th.go.drr.gps.domain.GpsData;

import com.opensymphony.xwork2.ModelDriven;

public class UploadExcelFile extends AbstractAction implements ModelDriven<GpsData>{
	
	private static final long serialVersionUID = 2061491566220002716L;
	private static Logger logger = Logger.getLogger(UploadExcelFile.class);

	private GpsData gpsData;
	
	private File gpsFile;
	private String gpsFileContentType;
	private String gpsFileFileName;	
	
//	private static String BASE_PATH = "E:/workspace/eclipse/indigo/drr/gps/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/webapps/files";
	
	public String form(){
		logger.info("upload file");
		return "form";
	}
	
	public String execute(){
		File f = new File(cache.findByKey(APPCONF.BASE_PATH.name()));
		if(f.exists())
			logger.info("file exist");
		logger.info("upload file:"+ gpsFile.length()+" file type:"+gpsFileContentType+" file name:"+gpsFileFileName);
		return SUCCESS;
	}
	
	@Override
	public GpsData getModel() {		
		return this.gpsData;
	}
	public File getGpsFile() {
		return gpsFile;
	}
	public void setGpsFile(File gpsFile) {
		this.gpsFile = gpsFile;
	}
	public String getGpsFileContentType() {
		return gpsFileContentType;
	}
	public void setGpsFileContentType(String gpsFileContentType) {
		this.gpsFileContentType = gpsFileContentType;
	}
	public String getGpsFileFileName() {
		return gpsFileFileName;
	}
	public void setGpsFileFileName(String gpsFileFileName) {
		this.gpsFileFileName = gpsFileFileName;
	}	
	
}
